// 查询传播图,渲染进行自动播放
(function() {
	ajax({
		method: 'GET',
		url: BASE_URL + '/api_banner?bannerId=1',
		type: 'JSON',
		callback: function(data) {
			let bannerList = document.querySelector(".swiper-wrapper")
			let bannerData = data.data
			console.log(bannerData)
			let text = ''
			bannerData.forEach((item) => {
				text += "<div class='swiper-slide'><img src=" + item.goods_thumb + "></div>"
			})
			bannerList.innerHTML = text
			var mySwiper = new Swiper('.swiper', {
				autoplay: {
					delay: 1000, //1秒切换一次
				},
				loop: true,
				pagination: {
					el: '.swiper-pagination',
					type: 'bullets'
				},
				navigation: {
					nextEl: '.swiper-button-next',
					prevEl: '.swiper-button-prev',
				}
			});
		}
	})
})();
// 查询热门商品,渲染
(function() {
	ajax({
		method: 'GET',
		url: BASE_URL + '/api_goods',
		type: 'JSON',
		callback: function(data) {
			let hotGoodData = data.data
			let hotGoodList = document.querySelector(".hot>ul")
			let text = ''
			hotGoodData.forEach(item => {
				text += "<li>" +
					"<div class='hot_img'>" +
					"<img src='" + item.goods_thumb + "'>" +
					"<p>良仓双12</p>" +
					"<img src='img/double12.jpg'>" +
					"</div>" +
					"<div class='good_info'>" +
					"<p>" +
					"<span>" + item.goods_name + "</span><br>" +
					item.goods_desc +
					"</p>" +
					"</div>" +
					"<div class='good_other'>" +
					"<div>" +
					"<img src='" + item.brand_thumb + "'>" +
					"<span>" + item.brand_name + "</span>" +
					"<span class='nice'>" + item.star_number + "</span>" +
					"</div>" +
					"</div>" +
					"</li>"
			})
			hotGoodList.innerHTML = text
		}
	})
})();